
; Real time clock and weather mod.
; Even CyQ liked this mod. 8-)

004F: create_thread TimeMod  

...

:TimeMod
0004: $weather = 0  ;; integer values 
0006: 16@ = 0  ;; integer values  - Reset internal timer

:TimeLoop
0001: wait 500 ms 
; The time must be read before it can be set because
; the time changes when the player starts certain
; missions, dies, gets arrested or saves the game.
00BF: 1@ = current_time_hours, 2@ = current_time_minutes 
00C0: set_current_time 1@ 2@ 

; The weather changes every time the time is changed using
; the set_current_time code. The force_weather code fixes
; that. Without it, the weather would go bananas.
; The weather changes every hour.
01B5: force_weather $weather 
00D6: if 0 
0019:   16@ > 59999  ;; integer values  - if internal timer >= 1 minute
004D: jump_if_false TimeLoop 
0006: 16@ = 0  ;; integer values  - reset the internal timer
000A: 2@ += 1  ;; integer values 
00D6: if 0 
0019:   2@ > 59  ;; integer values 
004D: jump_if_false TimeModL2 
0006: 2@ = 0  ;; integer values 
000A: 1@ += 1  ;; integer values 

; This code makes the weather mission specific if
; the player is on a mission. Add
; 0004: $weather = <mission specific weather>
; to all force_weather and set_weather codes in
; all the missions (about 25 of these)
00D6: if 0 
0038:   $ONMISSION == 0  ;; integer values 
004D: jump_if_false TimeModL3 
0008: $weather += 1  ;; integer values 
00D6: if 0 
0018:   $weather > 4  ;; integer values 
004D: jump_if_false TimeModL3 
0004: $weather = 0  ;; integer values 

:TimeModL3
00D6: if 0 
0019:   1@ > 23  ;; integer values 
004D: jump_if_false TimeModL2 
0006: 1@ = 0  ;; integer values 

:TimeModL2
; Here, the time is NOT read before it is set.
00C0: set_current_time 1@ 2@ 
0002: jump TimeLoop 
